import urllib.request
import urllib.parse
import json
content = input('请输入要翻译的内容：')
url = 'http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule'
data = {}
data['i']= content
data['from']=' AUTO'
data['to']=' AUTO'
data['smartresult']='dict'
data['client']='fanyideskweb'
data['salt']='16037227564416'
data['sign']='efc2829e49cd53353512930b9317aa0c'
data['lts']='1603722756441'
data['bv']=' cc652a2ad669c22da983a705e3bca726'
data['doctype']='json'
data['version']='2.1'
data['keyfrom'] ='fanyi.web'
data['action']='FY_BY_REALTlME'
data = urllib.parse.urlencode(data).encode('utf-8')
response = urllib.request.urlopen(url,data)


html = response.read().decode('utf-8')

target = json.loads(html)
type(target)
print(target['translateResult'][0][0]['tgt'])